/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.mahjongcalc.model;

import org.me.mahjongcalc.error.MHandFullException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Observable;

/**
 *
 * @author xelinis
 */
public class MHand extends Observable {

	public static final int MAX_TILES = 18;
	private List<MTile> tiles = new ArrayList<MTile>( MAX_TILES );
	private boolean closed = true;

	public void addTile( MTile tile ) throws MHandFullException {

		if ( tiles.size() == MAX_TILES ) {
			throw new MHandFullException();
		}

		if ( tile != null ) {
			tiles.add( tile );
		}
	}

	public void addAllTiles( MTile[] tiles ) throws MHandFullException {
		for ( MTile t : tiles ) {
			addTile( t );
		}
	}

	public int size() {
		return tiles.size();
	}

	public MTile getTileAtIndex( int index ) {
		return tiles.get( index );
	}

	public MTile removeTileAtIndec( int index ) {
		return tiles.remove( index );
	}

	public void swapTiles( int x, int y ) {
		Collections.swap( tiles, x, y );
	}

	public boolean isClosed() {
		return closed;
	}

	public void setClosed( boolean closed ) {
		this.closed = closed;
	}

	public int getPoints() {
		return 0;
	}
}
